﻿using System;
using System.Collections.Generic;
using System.Data;
using System.IO;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Web;
using System.Web.Http;
using System.Xml;
using System.Xml.Serialization;
using bmapi.HelperClass;
using bmapi.Models;
using bmapi.Models.CADModel;
using bmapi.Models.DataEntity;
using ICSharpCode.SharpZipLib.Zip;
using Newtonsoft.Json.Linq;
using static bmapi.Models.ShowModel;

namespace bmapi.Controllers
{
    [Route("order"),JwtAuthActionFilter]
    public class OrderController : PageController
    {

        // PUT: api/Order/5
        /// <summary>
        /// 改变已有订单号的j是否加急状态  
        /// </summary>
        /// <param name="obj"></param>
        /// <returns></returns>
        [HttpPut]
        public HttpResponseMessage Put(dynamic obj)
        {
            SQLCommand sc = null;
            if (obj == null)
                return AssistFun.toJson(new { status = 201, tip = "参数不能为空" });
            else
            {
                int id = Convert.ToInt32(obj.Id);
                int rank = Convert.ToInt32(obj.rank);
                try
                {
                    string sql = "update Order_tb set rank=@rank where id=" + id;
                    sc = new SQLCommand(sql,"@rank",rank);
                    int res = sc.ExecuteNonQuery();
                    if (res == 1)
                    {
                        return AssistFun.toJson(new { status = 200, tip = "成功" });
                    }
                    else
                    {
                        return AssistFun.toJson(new { status = 201, tip = "失败" });
                    }                        
                }
                catch (Exception e)
                {
                    return AssistFun.toJson(new { status = 201, tip = "失败 异常："+e.Message }); ;
                }
            }
        }
     

        #region 删除订单  近两个月的订单
        /// <summary>
        /// 删除订单  近两个月的订单  没有删除相关文件夹 暂定
        /// </summary> 
        /// <param name="Id"></param>
        [HttpDelete]
        public HttpResponseMessage DeleteOrder(int Id)
        {
            try
            {
                string selOrder = "select creater_time,bind_id from Order_tb where id=@id";
                SQLCommand sc = new SQLCommand(selOrder, "@id", Id);
                DataRow  dr= sc.ExecuteOneRow();
                if(dr == null)
                    return AssistFun.toJson(new { status = 201, tip = "该生产单数据不完整，暂时无法删除" });
                if(Convert.ToInt32(dr["bind_id"])!=0)
                    return AssistFun.toJson(new { status = 201, tip = "被绑定的生产单不允许删除" });
                TimeSpan ts = DateTime.Now - Convert.ToDateTime(dr["creater_time"]);
                 //两个时间相差的天数  
                 if(ts.Days>61)
                    return AssistFun.toJson(new { status = 201, tip = "该生产单是两个月以前的，禁止删除" });
                return RealDeleteOrder(Id);
            }
            catch (Exception ex)
            {
                WriteLog("DeleteOrder 异常：", ex.Message);
                return AssistFun.toJson(new { status = 201, tip = "失败" }); 
            }
            
        }
        private HttpResponseMessage RealDeleteOrder(int Id)
        {
            List<SQLCommand> cmds = new List<SQLCommand>();
            SQLCommand sc = null;
            string sql = "delete from Order_tb where id=@id";
            cmds.Add(sc = new SQLCommand(sql, "@id", Id));
            sql = "delete from Bed_tb where order_id=@id"; //床表  
            cmds.Add(sc = new SQLCommand(sql, "@id", Id));
            sql = "delete from LSH_tb where order_id=@id"; //流水号 
            cmds.Add(sc = new SQLCommand(sql, "@id", Id));
            sql = "delete from PC_tb where pc_id=@id"; //流程表 
            cmds.Add(sc = new SQLCommand(sql, "@id", Id));
            sql = "delete from Pod_tb where order_id=@id"; //pod表 
            cmds.Add(sc = new SQLCommand(sql, "@id", Id));
            sql = "delete from Task_tb where id=@id"; //日志表 
            cmds.Add(sc = new SQLCommand(sql, "@id", Id));
            int res = SQLCommand.ExecTran(cmds);
            if (res == 1)
                return AssistFun.toJson(new { status = 200, tip = "成功" });
            else
                return AssistFun.toJson(new { status = 201, tip = "失败" });
        }
        #endregion

        #region  生产单查询  
        //生产单查询  
        [HttpGet, Route("orderSearch")]
        public HttpResponseMessage SelectProductOrder(int page = 1, int limit = 10, string ModelName = null, string OrderId = null, string cusName = null, DateTime? sTime = null, DateTime? eTime = null, int Yield = -1, string State = "1", int bingNum = -1)
        {
            int loginid = GetCrrentIDByToken();
            if (loginid == 0)
                return AssistFun.toJson(new { status = 201, tip = "工号不存在", data = "" });
            User user = GetUserByLoginID(loginid);
            try
            {
                string fields = "(select count(pod_id) from Pod_tb where Pod_tb.order_id = Order_tb.id) as Pod,(select count(id) from Bed_tb where Bed_tb.order_id=Order_tb.id) as Bed, Order_tb.id as Id, Order_tb.name as OrderId,Order_tb.mCode,Order_tb.rank,Order_tb.nature,Order_tb.erp_custname as cusName,Order_tb.finish_time as fTime,Model_tb.name as ModelName,creater_time as Time,quantity as Yield,Order_tb.state as State,o_model_id as ModelId,Order_tb.bind_id as BindId,PL_tb.type as type ";
                string table = "Order_tb join Model_tb on  Order_tb.o_model_id=Model_tb.id join PL_tb on order_tb.o_PLID=PL_tb.id ";
                string where = PingJieCmdForOrder(user.PLID, ModelName, OrderId, cusName, sTime, eTime, Yield, State, bingNum);
                int totalPage, totals;
                //string order = " Order_tb.creater_time desc"; 
                string order = " Order_tb.rank desc,Order_tb.finish_time asc ";
                if (bingNum !=-1 && bingNum != 0)
                    order = " Order_tb.bind_id desc";

                //DataTable dt = SQLCommand.GetDataListByPage(table, fields, order, where, limit, page, out totalPage, out totals); 
                DataTable dt = null;
                SQLCommand.GetDataListByPage(table, fields, order, where, limit, page, out totalPage, out totals,out dt);
                if (dt == null)
                    return AssistFun.toJson(new { status = 201, tip = "暂时没有生产单信息", data = "" });
                else
                {

                    if (SQLCommand.IsOracle)
                    {
                        List<OrcProductInfo> producs =  AssistFun.DataTableToList<OrcProductInfo>(dt);
                        return AssistFun.toJson(new { status = 200, tip = "成功", data = new { total = totals, rows = producs } });
                    }
                    else

                    {
                        List<SqlProductInfo> producs =  AssistFun.DataTableToList<SqlProductInfo>(dt);
                        return AssistFun.toJson(new { status = 200, tip = "成功", data = new { total = totals, rows = producs } });
                    }                    
                }
            }
            catch (Exception e)
            {
                return AssistFun.toJson(new { status = 201, tip = e.Message, data = "" });
            }
        }

        private string PingJieCmdForOrder(int plid, string modelname, string OrderId, string cusName=null , DateTime? sTime=null , DateTime? eTime=null, int yield = -1, string State = null, int bingNum=-1)
        {
            string sql = "";
            if (plid.ToString()!=null&&plid > 0)
            {
                sql += " and Order_tb.o_PLID=" + plid;
            }
            if (modelname != null)
                sql += string.Format(" and Model_tb.name like '%{0}%' ", modelname);
            if (OrderId != null)
                sql += string.Format(" and Order_tb.name like '%{0}%'", OrderId);
            if (cusName != null)
                sql += string.Format(" and erp_custname like '%{0}%'", cusName);
            if (sTime != null)
                if(SQLCommand.IsOracle)
                    sql += " and creater_time>=to_date('"+Convert.ToDateTime(sTime).ToShortDateString()+ "','yyyy/mm/dd hh24-mi-ss')";
                else
                    sql += " and creater_time>=CONVERT(varchar(100), '"+sTime+"', 120)";
            if (eTime != null)
                if(SQLCommand.IsOracle)
                    sql += " and creater_time<=to_date('"+eTime+ "','yyyy/mm/dd hh24-mi-ss')";
                else
                    sql += " and creater_time<=CONVERT(varchar(100), '" + eTime + "', 120)";
            if (yield.ToString()!=null && yield > 0)
            {
                sql += " and quantity>=" + yield;
            }
            if (State != null)
            {
                if (Convert.ToInt32(State) == 1)
                {
                    if (SQLCommand.IsOracle)
                        sql += " and to_char(finish_time,'yyyy-mm-dd hh24:mi:ss')>to_char(sysdate,'yyyy-mm-dd hh24:mi:ss') and Order_tb.state=1 ";
                    else
                        sql += " and GETDATE()<finish_time and Order_tb.state=1 ";
                }
                if (Convert.ToInt32(State) == 3)
                {
                    if (SQLCommand.IsOracle)
                        sql += " and to_char(finish_time,'yyyy-mm-dd hh24:mi:ss')<to_char(sysdate,'yyyy-mm-dd hh24:mi:ss') and Order_tb.state=1 ";
                    else
                        sql += " and GETDATE()>finish_time and Order_tb.state=1 ";
                }
                if (Convert.ToInt32(State) == 0)
                    sql += " and Order_tb.state=0 ";
                if (Convert.ToInt32(State) == 2)
                    sql += " and Order_tb.state=2 ";
            }
            if (bingNum !=-1)
            {
                if (bingNum == 0)
                {
                    sql += sql + " and Order_tb.bind_id=0";
                }
                else
                {
                    sql += sql + "and Order_tb.bind_id !=0";
                }
            }
            return sql;
        }

        #endregion

        #region 生产单绑定
        /// <summary>
        /// 生产单绑定   1.物料相同(大前提) 2.样式相同   3.样式不同  4.多个订单的人数 件数  以及人员相同    可绑定的情况  12 和 134
        /// </summary>
        /// <param name="orderId"></param>
        /// <returns></returns>
        [HttpPut, Route("binding")]
        public HttpResponseMessage Binding(string[] orderId)
        {
            //多个生产单邦定的话, 其中有一个是主生产单,其bind_id = id,其他生产单的bind_id = 主生产单的id
            SQLCommand sc = null;
            string sql = "";
            if (orderId.Length < 2)
                return AssistFun.toJson(new RespondModel(201, "至少要两个订单才可以进行绑定操作"));
            else
            {
                DataTable dt = null;
                string orderids = AssistFun.ArryToString(orderId);              
                //判断物料信息 
                sql = "select distinct m_dose,l_dose,f_dose,mCode,mColor from Order_tb where id in (" + orderids + ")";
                sc = new SQLCommand(sql);
                dt = sc.ExecuteScalars();
                if(dt==null)
                    return AssistFun.toJson(new RespondModel(201, "没有找生产单相关信息"));
                if (dt.Rows.Count > 1)
                    return AssistFun.toJson(new RespondModel(201, "生产单中物料信息不一致" + dt.Rows.Count));
                else
                {
                    //判断订单的进程是否进行到37 进行到37 则不可以绑定  其余情况无所谓
                    sql = "select max(code) as code from Task_tb where id in(" + orderids + ") ";
                    sc = new SQLCommand(sql);
                    string maxcode = sc.ExecuteScalar();
                    if (maxcode != null && Convert.ToInt32(maxcode).Equals(37))
                        return AssistFun.toJson(new RespondModel(201, "其中订单进行到排料，无法进行绑定"));

                    ////判断样式  暂时不做判断 (后期完善) 样式不一致判断lsh信息是否一致？是的  样式一致是否还需要判断lsh信息？ 不需要
                    sql = "select distinct o_model_id from Order_tb where id in(" + orderids + ")";
                    sc = new SQLCommand(sql);
                    dt = sc.ExecuteScalars();
                    if (dt != null && dt.Rows.Count == 1)//生产单样式一致 允许绑定
                        return BingDingOrder(orderId);
                    else
                    {
                        #region 套绑定 样式不一致  要求每个人在每个订单中对应的件数一致(一件上衣对应一条裤子)  人员一致
                        sql = "select distinct count(erp_id) as people from LSH_tb where order_id in (" + orderids+") group by order_id";
                        sc = new SQLCommand(sql);
                        dt = sc.ExecuteScalars();
                        if (dt == null || dt.Rows.Count>1)
                            return AssistFun.toJson(new RespondModel(201, "其中生产单异常，人员不一致"));
                        else
                        {
                            //每个订单的人数
                            int people = Convert.ToInt32(dt.Rows[0]["people"]);
                            sql = "select erp_id,tdMulit from LSH_tb where order_id in("+orderids+") group by erp_id,tdMulit ";
                            sc = new SQLCommand(sql);
                            dt = sc.ExecuteScalars();
                            if (dt == null)
                                return AssistFun.toJson(new RespondModel(201, "其中生产单异常，人员不一致"));
                            else
                            {
                                if(dt.Rows.Count == people)
                                    return BingDingOrder(orderId);
                                else
                                    return AssistFun.toJson(new RespondModel(201, "生产单无法绑定，因为对应的套数不一致"));
                            }
                        }
                        #endregion

                        ////人数是否一致  
                        //sql = "select distinct sum(tdMulit) from LSH_tb where order_id in(" + orderids + ") group by order_id";
                        //sc = new SQLCommand(sql);
                        //dt = sc.ExecuteScalars();
                        //if(dt==null || dt.Rows.Count>1)
                        //    return AssistFun.toJson(new RespondModel(201, "件数不一致，禁止绑定 "));
                        ////判断lsh信息  人员以及人数要求一致 erpid==人员ID  不同订单 同一个人的人员ID一致
                        //sql = "select distinct count(erp_id) as people from LSH_tb where order_id in(" + orderids + ") group by order_id";
                        //sc = new SQLCommand(sql);
                        //dt = sc.ExecuteScalars(); 
                        //if (dt == null || dt.Rows.Count>1)
                        //    return AssistFun.toJson(new RespondModel(201, "其中生产单异常，人员不一致"));
                        //else
                        //{
                        //    int people = Convert.ToInt32(dt.Rows[0]["people"]);
                        //    sql = "select distinct erp_id from LSH_tb where order_id in(" + orderids + ")";
                        //    sc = new SQLCommand(sql);
                        //    dt = sc.ExecuteScalars();
                        //    if (dt == null)
                        //        return AssistFun.toJson(new RespondModel(201, "找不到生产单的人员信息"));
                        //    else
                        //    {
                        //        if(dt.Rows.Count== people)
                        //            return BingDingOrder(orderId);
                        //        else
                        //            return AssistFun.toJson(new RespondModel(201, "生产单无法绑定，因为其人数或者人员不一致"));
                        //    }   
                        //}                        
                    }
                }
            }                

        }
        //订单绑定操作  
        private HttpResponseMessage BingDingOrder(string[] orderId)
        {
            SQLCommand sc = null;
            List<SQLCommand> cmds = new List<SQLCommand>();
            for (int i = 0; i < orderId.Length; i++)
            {
                sc = new SQLCommand("UPDATE Order_tb SET bind_id=@bindid WHERE id=@orderid");
                sc.Add("@bindid", orderId[0]);
                sc.Add("@orderid", orderId[i]);
                cmds.Add(sc);

                sc = new SQLCommand("UPDATE PC_tb SET bind_id=@bindid WHERE pc_id=@pcid");
                sc.Add("@bindid", orderId[0]);
                sc.Add("@pcid", orderId[i]);
                cmds.Add(sc);
            }
           int res = SQLCommand.ExecTran(cmds);
            if (res > 0)
                return AssistFun.toJson(new RespondModel(200, "成功绑定"));
            else
                return AssistFun.toJson(new RespondModel(201, "绑定失败"));
        }
        
        #endregion    

        #region 生产单解除绑定
        [HttpPut, Route("removebinding")]
        public HttpResponseMessage RemoveBinding(string[] bindId)
        {
            int count = 0;
            List<SQLCommand> cmds = new List<SQLCommand>();
            SQLCommand sc = null;
            for (int i = 0; i < bindId.Length; i++)
            {
                if (Convert.ToInt32(bindId[i]) != 0)
                {
                    sc = new SQLCommand("UPDATE Order_tb SET bind_id=0 WHERE bind_id=@bindid", "@bindid", bindId[i]);
                    cmds.Add(sc);
                    sc = new SQLCommand("UPDATE PC_tb SET bind_id=0 WHERE bind_id=@bindid", "@bindid", bindId[i]);
                    cmds.Add(sc);
                }
                else
                    return AssistFun.toJson(new RespondModel(201, "选定对象未绑定"));
            }

            count = SQLCommand.ExecTran(cmds);
            if (count > 0)
                return AssistFun.toJson(new RespondModel(200, "修改成功"));
            else
                return AssistFun.toJson(new RespondModel(201, "修改失败"));
        }
        #endregion

        #region 生产单下载
        /// <summary>
        /// 生产单文件打包下载 
        /// </summary>  
        /// <param name="Id"></param>
        /// <returns></returns> 
        [HttpGet, Route("downOrder")]
        public HttpResponseMessage DownOrder(int Id, string token)
        {
            try
            {
                int loginid = GetCrrentIDByToken(token);
                if (loginid == 0)
                    return AssistFun.toJson(new { status = 201, tip = "你无权下载" });

                string sql = "select name,state from Order_tb where id=@orderid";
                SQLCommand sc = new SQLCommand(sql, "@orderid", Id);
                DataRow dr = sc.ExecuteOneRow();
                if (dr == null)
                    return AssistFun.toJson(new { status = 201, tip = "不存在该生产单信息" });
                else
                {
                    string orderName = dr["name"].ToString();
                    int state = Convert.ToInt32(dr["state"]);
                    string orderPath = "";
                    if(state==0)
                        return AssistFun.toJson(new { status = 201, tip = "该生产单已经废弃，禁止下载" });
                    if (state == 1)
                        orderPath = GetPCPath(orderName);
                    if (state == 2)
                        orderPath = GetOrderFile(Id, null);
                    string TartgetFile = orderPath.Substring(0, orderPath.LastIndexOf(@"\")) + "\\" + orderName + ".zip";
                    using (ZipOutputStream ComStream = new ZipOutputStream(File.Create(TartgetFile)))
                    {
                        ComStream.SetLevel(6);      //压缩等级
                        if (!Directory.Exists(orderPath))
                            return AssistFun.toJson(new { status = 201, tip = "不存在生产单" + orderName + "的目录" });
                        //压缩文件 有同名压缩文件会自动替换                    
                        ZipFloder(orderPath, ComStream, orderPath);
                    }
                    //成功压缩  下载文件 
                    return Download(TartgetFile);
                }
               
            }
            catch (Exception e)
            {
                WriteDebug("DownOrder", "生产单下载异常：" + e.Message);
                return AssistFun.toJson(new { status = 201, tip = e.Message });
            }
        }
       

        #endregion

        #region  PLAN Excel文件下载 
        /// <summary>
        /// PLAN文件下载    
        /// </summary>  
        /// <param name="OrderId">订单号</param>
        /// <param name="State">订单状态</param>
        [HttpGet,Route("downplan"),JwtAuthActionFilter]
        public HttpResponseMessage DowonPLAN(int BindId, int State, int Id,string type="plan",string token = "")
        {
            //if (State != 2)
            //    return AssistFun.toJson(new { status = 201, tip = "该订单未完成，无法下载"+type+"文件" });
            if (BindId != 0)
                Id = FindMainOrder(BindId,State);
            string path = GetOrderFile(Convert.ToInt32(Id), ".plan");
            if (!type.Equals("plan"))
                path= GetOrderFile(Convert.ToInt32(Id), null)+"\\mark.xls";

            WriteDebug("DowonPLAN", "path：" + path);
            if (path == null)
                return AssistFun.toJson(new { status = 201, tip = "找不到"+ type + "文件" });
            if (!File.Exists(path))
                return AssistFun.toJson(new { status = 201, tip = "找不到"+ type + "文件" });
            else
                return Download(path);
        }
        /// <summary>
        /// 查找记录完整信息的订单
        /// </summary> 
        /// <param name="bind_id"></param>
        private int FindMainOrder(int bind_id,int State)
        {
            string sql = "";            
            if (bind_id != 0)
            {
                sql = "select id from Order_tb where state=@state and id=@bindid ";
                SQLCommand sc = new SQLCommand(sql);
                sc.Add("@bindid", bind_id);
                sc.Add("@state", State);
                string res = sc.ExecuteScalar();
                if (res == null)
                    return 0;
                else
                    return Convert.ToInt32(res);
                
            }
            return 0;
        }

        #endregion

        #region  量体信息
        /// <summary>
        /// 量体信息
        /// </summary>
        /// <param name="OrderId">订单名</param>
        /// <param name="Id">订单ID</param>
        /// <param name="State">订单状态</param>
        /// <returns></returns>
        [HttpGet, Route("measurebodyinfo")]
        public HttpResponseMessage GetMeasureBodyInfo(int Id, string OrderId, int State, int limit = 10, int page = 1)
        {
            try
            {
                string xmlPath = null;
                if (State == 0)
                    return AssistFun.toJson(new { status = 201, tip = "生产单已废弃", data = "" });

                if (State == 1)
                    xmlPath = GetPCPath(OrderId) + "\\" + OrderId + ".xml";
                if (State == 2)
                    xmlPath = this.GetOrderFile(Id, ".xml");

                if (xmlPath == null)
                    return AssistFun.toJson(new { status = 201, tip = "找不到文件", data = "" });
                WriteDebug("GetMeasureBodyInfo", "XML路径：" + xmlPath);

                XmlDocument doc = new XmlDocument();
                doc.Load(xmlPath);
                td tt = null;
                using (StringReader rdr = new StringReader(doc.InnerXml))
                {
                    //声明序列化对象实例serializer   
                    XmlSerializer serializer = new XmlSerializer(typeof(td));
                    //反序列化，并将反序列化结果值赋给变量tt
                    tt = (td)serializer.Deserialize(rdr);
                }
                //流水号匹配  
                List<PersonLsh> personList = MathLSH(tt.personList, Id);
                if (personList.Count > 0)
                    return AssistFun.toJson(new { status = 200, tip = "成功", data = new { total = personList.Count, rows = new { personList = personList.OrderBy(p => p.LSH), measureName = tt.measureName } } });
                else
                    return AssistFun.toJson(new { status = 201, tip = "量体没有对应的流水号信息", data = "" });

            }
            catch (Exception ex)
            {
                WriteDebug("GetMeasureBodyInfo", "异常：" + ex.Message);
                return AssistFun.toJson(new { status = 201, tip = ex.Message, data = "" });
            }

        }

        /// <summary>
        /// 流水号匹配 
        /// </summary> 
        /// <param name="personList"></param>
        /// <param name="id">订单id</param>
        private List<PersonLsh> MathLSH(List<person> personList, int id)
        {
            string sql = "select erp_id,LSH from LSH_tb where order_id=@orderid";
            SQLCommand sc = new SQLCommand(sql, "@orderid", id);
            DataTable dt = sc.ExecuteScalars();
            //获取特体
            sql = "select distinct Pod_tb.pod from Pod_tb inner join LSH_tb on Pod_tb.order_id = LSH_tb.order_id and Pod_tb.pod = LSH_tb.pod where Pod_tb.order_id = @orderid";
            sc = new SQLCommand(sql, "@orderid", id);
            DataTable pods = sc.ExecuteScalars();

            List<LSHInfo> lshList = new List<LSHInfo>();
            List<PersonLsh> personLshs = new List<PersonLsh>();
            if (dt == null)
                return personLshs;
            else
            {
                List<int> allPod = new List<int>();
                if (pods != null)
                    allPod = pods.AsEnumerable().Select(d => d.Field<int>("pod")).ToList();
                lshList = AssistFun.DataTableToList<LSHInfo>(dt);
                foreach (LSHInfo lsh in lshList)
                {

                    foreach (person per in personList)
                    {
                        if (lsh.erp_id == per.ID)
                        {
                            PersonLsh perlsh = null;
                            if (allPod.Exists(o => o.Equals(per.pod)))
                                perlsh = new PersonLsh(per, lsh.LSH, true);
                            else
                                perlsh = new PersonLsh(per, lsh.LSH);
                            personLshs.Add(perlsh);
                            break;
                        }
                    }
                }
            }
            return personLshs;
        }

        #endregion

        #region 物料信息 
        [HttpGet, Route("materialinfo")]
        public HttpResponseMessage GetMaterial(int Id)
        {
            string sql = string.Format("select m_dose,l_dose,f_dose,mCode,mColor from Order_tb where id={0}",Id);
            SQLCommand sc = new SQLCommand(sql);
            DataRow dr = sc.ExecuteOneRow();
            if (dr == null)
                return AssistFun.toJson(new { status = 201, tip = "无信息", data = "" });
            else
            {
                string mdose = dr["m_dose"].ToString();
                string ldose = dr["l_dose"].ToString();
                string fdose = dr["f_dose"].ToString();
                string mCode = dr["mCode"].ToString();
                string mColor = dr["mColor"].ToString();
                return AssistFun.toJson(new { status = 200, tip = "成功", data = new { total = 1, rows = new { mdose,ldose,fdose,mCode,mColor } } });
            }
        }

        #endregion

    }
}
